//
//  EAScoreViewController.m
//  WhatToEat
//
//  Created by 方力 on 15/11/2.
//  Copyright © 2015年 Mac. All rights reserved.
//

#import "EAScoreViewController.h"

@interface EAScoreViewController ()
@property(strong,nonatomic)UILabel * scoreLabel;
@end

@implementation EAScoreViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    
    self.navigationItem.title=@"用户评分";
    
    [self updateUI];
}


-(void)updateUI
{


    
        self.edgesForExtendedLayout=UIRectEdgeTop;
//    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithTitle:@"保存" style:0 target:self action:@selector(toSaveAction)];
    
    UIImageView *bgView=[[UIImageView alloc] init];
    
    bgView.backgroundColor=[UIColor redColor];
    
    UIImage * img=[[UIImage imageNamed:@"bj_jb"] stretchableImageWithLeftCapWidth:1 topCapHeight:2];
    
    bgView.image=img;
    

    
    self.navigationController.navigationBarHidden=YES;
    
    
    
    
    

    
    
    
    
    
    
    [self.view addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(self.view);
        make.center.mas_equalTo(self.view);
    

        
    }];
    

    UILabel * l=[[UILabel alloc] init];
    
    l.text=@"祝您身体健康,心情越快！";
    [self.view addSubview:l];
    l.font=kFont(15);
    l.textColor=[UIColor whiteColor];
    [self.view addSubview:l];
    
    [l mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view.top).with.offset(100);
        make.centerX.mas_equalTo(self.view);
        
        
    }];
    
    
    UIImageView * centerImageView=[[UIImageView alloc] init];
    
    centerImageView.image=[UIImage imageNamed:@"pf"];
    [self.view addSubview:centerImageView];
    
    [centerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
    
        make.top.mas_equalTo(l.mas_bottom).with.offset(55);

        make.centerX.mas_equalTo(self.view);
        
        
    }];
    
    
    UIImageView * bottonImageView=[[UIImageView alloc] init];
    
    bottonImageView.image=[UIImage imageNamed:@"shucai"];
    
    [self.view addSubview:bottonImageView];
    
    [bottonImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.mas_equalTo(self.view.mas_bottom);

        make.centerX.mas_equalTo(self.view);
        
        
    }];
    
    
   self.scoreLabel =[[UILabel alloc] init];
    

    self.scoreLabel.textColor=[UIColor colorWithRed:255/255.0 green:236/225.0 blue:164/255.0 alpha:1];
    

    self.scoreLabel.font=kFont(40);
    
    self.scoreLabel.text=self.scores;
    
    [centerImageView addSubview:self.scoreLabel];
    
    [self.scoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerX.mas_equalTo(centerImageView);
        
        make.centerY.mas_equalTo(centerImageView);
        
    }];
    
    
    UIButton * backBtn=[[UIButton alloc] init];
    
    
    [self.view addSubview:backBtn];
    
    [backBtn setImage:[UIImage imageNamed:@"back"] forState:0];
    
    [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.view.mas_top).with.offset(30);
        
        make.left.mas_equalTo(self.view.mas_left).with.offset(10);
        
        make.size.mas_equalTo(CGSizeMake(44, 33));
        
        
    }];

    backBtn.tag=1;
    
    [backBtn addTarget:self action:@selector(toSaveAction:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    
    UIButton * rightBtn=[[UIButton alloc] init];
    
    
    [self.view addSubview:rightBtn];
    
    [rightBtn setTitle:@"保存" forState:0];
    
    [rightBtn setTitleColor:[UIColor whiteColor] forState:0];
    
    [rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.view.mas_top).with.offset(30);
        
        make.right.mas_equalTo(self.view.mas_right).with.offset(-10);
        
        make.size.mas_equalTo(CGSizeMake(44, 33));
        
        
    }];
    
    rightBtn.tag=2;
    [rightBtn addTarget:self action:@selector(toSaveAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UILabel * titleLable=[[UILabel alloc] init];
    
    titleLable.font=kFont(22);
    
    titleLable.textColor=[UIColor whiteColor];
    titleLable.text=@"用餐评分";
    [self.view addSubview:titleLable];
    
    
    [titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
       
        
        make.top.mas_equalTo(self.view.mas_top).with.offset(30);
        
        make.centerX.mas_equalTo(self.view);
        
  
        
    }];

}


-(void)toSaveAction:(UIButton *)btn
{
    
    
    switch (btn.tag) {
        case 1:
                 [self.navigationController popToRootViewControllerAnimated:YES];
            break;
        case 2:
            [SVProgressHUD showImage:nil status:@"保存用餐评分成功"];
            
            [self.navigationController popToRootViewControllerAnimated:YES];

            break;
        default:
            break;
    }
    
    


}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    
    

}


-(void)viewWillDisappear:(BOOL)animated
{

    [super viewWillDisappear:animated];
    
      self.navigationController.navigationBarHidden=NO;
     self.edgesForExtendedLayout=UIRectEdgeNone;

}


#pragma mark--测试动画
-(void)testCAShapeLayerAndCAGradientLayer
{



}



@end
